<?

dbconnect();

Function dbquery($query,$debug = 0) {

        global $msq_db;

	if($debug) {
		echo "<pre>";
		print_r($query);
		echo "</pre>";
	}

	$result = mysql_query($query) or dberror(
		"database query failure.<br>reason: " . mysql_error() . "<br>" .
		"query that failed:<br><br>$query<br><br>");

        return $result;
}

Function dberror($message, $level=E_USER_NOTICE) {
	$caller = next(debug_backtrace());
	trigger_error($message . 'called from <strong>'.$caller['file'].'</strong> on line <strong>'.$caller['line'].'</strong>'."\n<br />error handler", $level);

}

Function dbconnect() {

	# specify database parameters
	$db_user = "tru7h02_sether";
	$db_pass = "kegger";
	$db_name = "tru7h02_crux";

	$mysql_connection = mysql_connect("localhost", $db_user, $db_pass)
		or die ("<h3>could not connect to database</h3>");
	mysql_select_db ($db_name)
		or die ("<h3>error accessing database</h3>");

	return $msq_db;

}

Function dbclose($mysql_connection) {

		mysql_close($mysql_connection);

}

Function safe_number($input) {
	$buf = preg_replace("/\D/",'',$input);
	return $buf;
}

Function safe_string($input) {
	$buf = preg_replace("/[;\'\"\,]/",'',$input);
	return $buf;
}


?>
